
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>3.7 流程控制 & 函数 · gitbook电子书</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="面向对象.html" />
    
    
    <link rel="prev" href="变量&作用域&垃圾收集.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="../使用/使用.html">
            
                <a href="../使用/使用.html">
            
                    
                    md语法 & gitbook使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../面试题/面试题.html">
            
                <a href="../面试题/面试题.html">
            
                    
                    面试题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../面试题/html.html">
            
                <a href="../面试题/html.html">
            
                    
                    HTML
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../面试题/css.html">
            
                <a href="../面试题/css.html">
            
                    
                    CSS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../面试题/js.html">
            
                <a href="../面试题/js.html">
            
                    
                    JavaScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../面试题/vue.html">
            
                <a href="../面试题/vue.html">
            
                    
                    Vue
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../面试题/小程序.html">
            
                <a href="../面试题/小程序.html">
            
                    
                    小程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../面试题/编程题.html">
            
                <a href="../面试题/编程题.html">
            
                    
                    编程题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../html/">
            
                <a href="../html/">
            
                    
                    1. HTML
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../html/1.常用标签.html">
            
                <a href="../html/1.常用标签.html">
            
                    
                    1.1 常用标签
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../html/2.列表.html">
            
                <a href="../html/2.列表.html">
            
                    
                    1.2 列表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../html/3.表单.html">
            
                <a href="../html/3.表单.html">
            
                    
                    1.3 表单属性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../html/4.音频&视频.html">
            
                <a href="../html/4.音频&视频.html">
            
                    
                    1.4 ifame & audio & video
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../css/">
            
                <a href="../css/">
            
                    
                    2. CSS
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../css/1.选择器.html">
            
                <a href="../css/1.选择器.html">
            
                    
                    2.1 选择器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../css/2.字体样式.html">
            
                <a href="../css/2.字体样式.html">
            
                    
                    2.2 字体样式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../css/3.背景.html">
            
                <a href="../css/3.背景.html">
            
                    
                    2.3 背景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../css/4.盒子模型.html">
            
                <a href="../css/4.盒子模型.html">
            
                    
                    2.4 盒子模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../css/5.浮动.html">
            
                <a href="../css/5.浮动.html">
            
                    
                    2.5 浮动
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../css/6.定位和渐变.html">
            
                <a href="../css/6.定位和渐变.html">
            
                    
                    2.6 定位 & 渐变
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../css/7.过渡&变形.html">
            
                <a href="../css/7.过渡&变形.html">
            
                    
                    2.7 过渡 & 变形
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../css/8.动画.html">
            
                <a href="../css/8.动画.html">
            
                    
                    2.8 动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../css/9.滤镜.html">
            
                <a href="../css/9.滤镜.html">
            
                    
                    2.9 滤镜
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../css/10.布局.html">
            
                <a href="../css/10.布局.html">
            
                    
                    2.10 布局
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="./">
            
                <a href="./">
            
                    
                    3. JS
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="数据类型.html">
            
                <a href="数据类型.html">
            
                    
                    3.1 数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="语句.html">
            
                <a href="语句.html">
            
                    
                    操作符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="操作符.html">
            
                <a href="操作符.html">
            
                    
                    语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="函数.html">
            
                <a href="函数.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="基本类型和引用类型的值.html">
            
                <a href="基本类型和引用类型的值.html">
            
                    
                    基本类型和引用类型的值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="执行环境及作用域.html">
            
                <a href="执行环境及作用域.html">
            
                    
                    执行环境及作用域
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="垃圾收集.html">
            
                <a href="垃圾收集.html">
            
                    
                    垃圾收集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="Object类型.html">
            
                <a href="Object类型.html">
            
                    
                    Object类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9" data-path="Array类型.html">
            
                <a href="Array类型.html">
            
                    
                    Array类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="Date类型.html">
            
                <a href="Date类型.html">
            
                    
                    Date类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.11" data-path="string&array.html">
            
                <a href="string&array.html">
            
                    
                    3.2 String & Array
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.12" data-path="date.html">
            
                <a href="date.html">
            
                    
                    3.3 Date类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.13" data-path="正则表达式.html">
            
                <a href="正则表达式.html">
            
                    
                    3.4 RegExp类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.14" data-path="global&math.html">
            
                <a href="global&math.html">
            
                    
                    3.5 Global对象 & Math对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.15" data-path="变量&作用域&垃圾收集.html">
            
                <a href="变量&作用域&垃圾收集.html">
            
                    
                    3.6 变量 & 作用域 & 垃圾收集
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5.16" data-path="流程控制&函数.html">
            
                <a href="流程控制&函数.html">
            
                    
                    3.7 流程控制 & 函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.17" data-path="面向对象.html">
            
                <a href="面向对象.html">
            
                    
                    3.8 面向对象的程序设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.18" data-path="递归&冒泡&快速.html">
            
                <a href="递归&冒泡&快速.html">
            
                    
                    3.9 递归 & 冒泡 & 快速
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.19" data-path="定时器&防抖&节流.html">
            
                <a href="定时器&防抖&节流.html">
            
                    
                    3.10 定时器\防抖\节流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.20" data-path="DOM获取&DOM操作.html">
            
                <a href="DOM获取&DOM操作.html">
            
                    
                    3.11 DOM获取 & DOM操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.21" data-path="键盘事件&鼠标事件.html">
            
                <a href="键盘事件&鼠标事件.html">
            
                    
                    3.12 键盘事件 & 鼠标事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.22" data-path="事件冒泡&事件代理&事件绑定.html">
            
                <a href="事件冒泡&事件代理&事件绑定.html">
            
                    
                    3.13 事件冒泡\代理\绑定
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.23" data-path="this指向.html">
            
                <a href="this指向.html">
            
                    
                    3.14 this指向
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.24" data-path="Ajax&跨域.html">
            
                <a href="Ajax&跨域.html">
            
                    
                    3.15 Ajax & 跨域
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.25" data-path="Bom.html">
            
                <a href="Bom.html">
            
                    
                    3.16 BOM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.26" data-path="ES6.html">
            
                <a href="ES6.html">
            
                    
                    3.17 ES6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.27" data-path="js实例.html">
            
                <a href="js实例.html">
            
                    
                    3.18 js实例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../vue/">
            
                <a href="../vue/">
            
                    
                    4. Vue
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../vue/1.基础.html">
            
                <a href="../vue/1.基础.html">
            
                    
                    4.1 基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../vue/2.生命周期.html">
            
                <a href="../vue/2.生命周期.html">
            
                    
                    4.2 生命周期
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../vue/3.vuex.html">
            
                <a href="../vue/3.vuex.html">
            
                    
                    4.3 vuex
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../vue/4.原理.html">
            
                <a href="../vue/4.原理.html">
            
                    
                    4.4 深入响应式原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../vue/5.组件.html">
            
                <a href="../vue/5.组件.html">
            
                    
                    4.5 组件进阶
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../vue/6.规模化.html">
            
                <a href="../vue/6.规模化.html">
            
                    
                    4.6 规模化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../vue/7.过渡&动画.html">
            
                <a href="../vue/7.过渡&动画.html">
            
                    
                    4.7 过渡 & 动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../vue/8.可复用性&组合.html">
            
                <a href="../vue/8.可复用性&组合.html">
            
                    
                    4.8 可复用性 & 组合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../vue/9.工具.html">
            
                <a href="../vue/9.工具.html">
            
                    
                    4.9 工具
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../Node/">
            
                <a href="../Node/">
            
                    
                    5. Node
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../插件/">
            
                <a href="../插件/">
            
                    
                    插件
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >3.7 流程控制 & 函数</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x6D41;&#x7A0B;&#x63A7;&#x5236;">&#x6D41;&#x7A0B;&#x63A7;&#x5236;</h1>
<h3 id="&#x8FD0;&#x7B97;&#x7B26;">&#x8FD0;&#x7B97;&#x7B26;</h3>
<h5 id="1-&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;">1. &#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;</h5>
<pre><code class="lang-js">    <span class="hljs-comment">//+&#x5177;&#x6709;&#x52A0;&#x6CD5;&#x548C;&#x62FC;&#x63A5;&#x7684;&#x4F5C;&#x7528;&#xFF0C;+&quot;1&quot;&#x4F1A;&#x8F6C;&#x5316;&#x4E3A;&#x6570;&#x503C;1</span>
    <span class="hljs-built_in">console</span>.log( +<span class="hljs-string">&quot;1&quot;</span> + <span class="hljs-number">1</span> );
    <span class="hljs-comment">//-&#x53EA;&#x80FD;&#x662F;&#x51CF;&#x6CD5;&#x8FD0;&#x7B97;&#xFF0C;&#x5B57;&#x7B26;&#x4E32;&#x90FD;&#x4F1A;&#x8F6C;&#x4E3A;&#x6570;&#x503C;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&quot;1&quot;</span> - <span class="hljs-number">1</span> );
    <span class="hljs-comment">//&#x540C;&#x7406;&#xFF1A;&#x4E58;&#x9664;&#x4E5F;&#x662F;&#x5B57;&#x7B26;&#x4E32;&#x90FD;&#x4F1A;&#x8F6C;&#x4E3A;&#x6570;&#x503C;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&quot;1&quot;</span> * <span class="hljs-number">2</span> );
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&quot;1&quot;</span> / <span class="hljs-number">2</span> );
    <span class="hljs-comment">//&#x6C42;&#x4F59;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-number">5</span> % <span class="hljs-string">&quot;2&quot;</span> );

    <span class="hljs-keyword">var</span> a = <span class="hljs-number">0</span>;
    a += <span class="hljs-number">10</span>;
    <span class="hljs-comment">//&#x81EA;&#x589E; &#x5F53;&#x524D;&#x6570;&#x503C;+1</span>
    <span class="hljs-comment">//a++&#x5373;&#x662F;&#x5B8C;&#x6210;&#x5F53;&#x524D;&#x4EE3;&#x7801;&#x6267;&#x884C;&#x540E;&#x518D;&#x81EA;&#x589E;</span>
    <span class="hljs-comment">//++a&#x5148;&#x81EA;&#x589E;&#xFF0C;&#x518D;&#x4F7F;&#x7528;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&quot;&#x81EA;&#x589E;&quot;</span> , ++a );
    <span class="hljs-comment">//&#x81EA;&#x51CF;  &#x548C;&#x81EA;&#x589E;&#x540C;&#x7406;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&quot;&#x81EA;&#x51CF;&quot;</span> , --a );

    <span class="hljs-built_in">console</span>.log( a -=<span class="hljs-number">4</span> );
    <span class="hljs-built_in">console</span>.log( a *=<span class="hljs-number">4</span> );
    <span class="hljs-built_in">console</span>.log( a /=<span class="hljs-number">4</span> );
    <span class="hljs-built_in">console</span>.log( a %=<span class="hljs-number">4</span> );
</code></pre>
<h5 id="2-&#x6BD4;&#x8F83;&#x8FD0;&#x7B97;&#x7B26;">2. &#x6BD4;&#x8F83;&#x8FD0;&#x7B97;&#x7B26;</h5>
<pre><code class="lang-js">    <span class="hljs-built_in">console</span>.log( <span class="hljs-number">1</span> &gt; <span class="hljs-number">2</span> );
    <span class="hljs-built_in">console</span>.log( <span class="hljs-number">1</span> &lt; <span class="hljs-number">2</span> );
    <span class="hljs-built_in">console</span>.log( <span class="hljs-number">1</span> == <span class="hljs-number">2</span> );
    <span class="hljs-built_in">console</span>.log( <span class="hljs-number">1</span> &gt;= <span class="hljs-number">2</span> );
    <span class="hljs-built_in">console</span>.log( <span class="hljs-number">1</span> &lt;= <span class="hljs-number">2</span> );
    <span class="hljs-comment">//== &#x7B49;&#x4E8E;&#xFF0C;&#x4E0D;&#x5224;&#x65AD;&#x7C7B;&#x578B;&#xFF0C;&#x4F1A;&#x5E26;&#x6709;&#x9690;&#x5F62;&#x8F6C;&#x5316;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&apos;5 == &quot;5&quot;&apos;</span> , <span class="hljs-number">5</span> == <span class="hljs-string">&quot;5&quot;</span> );
    <span class="hljs-comment">//===&#x5168;&#x7B49; &#x8FDE;&#x540C;&#x7C7B;&#x578B;&#x4E5F;&#x8FDB;&#x884C;&#x6BD4;&#x8F83;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&apos;5 === &quot;5&quot;&apos;</span> , <span class="hljs-number">5</span> === <span class="hljs-string">&quot;5&quot;</span> );
    <span class="hljs-comment">//&#xFF01;=&#x4E0D;&#x7B49;&#x4E8E;  &#x4F1A;&#x5E26;&#x6709;&#x9690;&#x5F62;&#x8F6C;&#x5316;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&apos;5 &#xFF01;= &quot;5&quot;&apos;</span> , <span class="hljs-number">5</span> != <span class="hljs-string">&quot;5&quot;</span> );
    <span class="hljs-comment">//&#xFF01;==&#x4E0D;&#x5168;&#x7B49;&#x4E8E; &#x8FDE;&#x540C;&#x7C7B;&#x578B;&#x4E5F;&#x8FDB;&#x884C;&#x6BD4;&#x8F83;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&apos;5 &#xFF01;==&quot;5&quot;&apos;</span>,<span class="hljs-number">5</span> !==<span class="hljs-string">&quot;5&quot;</span> );

    <span class="hljs-keyword">var</span> num1 = prompt(<span class="hljs-string">&quot;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x6570;&#xFF0C;&#x662F;&#x5426;&#x5728;0&#x5230;10&#x4E4B;&#x95F4;&quot;</span>);
    <span class="hljs-comment">//&#x5199;&#x6CD5;&#x4E0D;&#x89C4;&#x8303;&#xFF0C;&#x53EA;&#x80FD;&#x5224;&#x65AD;&#x5230;0&lt;num1</span>
    <span class="hljs-comment">//&#x9519;&#x8BEF;&#x5199;&#x6CD5;&#xFF1A;console.log( 0 &lt; num1 &lt; 10 );</span>
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x662F;&#x5426;&#x5728;0&#x5230;10&#x4E4B;&#x95F4;&quot;</span> ,<span class="hljs-number">0</span> &lt; num1 &amp;&amp; num1 &lt; <span class="hljs-number">10</span> );
</code></pre>
<h5 id="3-&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;">3. &#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;</h5>
<pre><code class="lang-js">    <span class="hljs-comment">//&amp;&amp;&#x4E0E;&#xFF08;&#x8C01;&#x4E0E;&#x8C01;&#xFF0C;&#x5E76;&#x5217;&#x5173;&#x7CFB;&#xFF09;&#x771F;&#x771F;&#x4E3A;&#x771F;&#xFF0C;&#x771F;&#x5047;&#x4E3A;&#x5047;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-literal">false</span> &amp;&amp; <span class="hljs-literal">false</span> );
    <span class="hljs-comment">//||&#x6216;&#xFF08;&#x53D6;&#x4EFB;&#x610F;&#x4E00;&#x4E2A;&#x4E3A;&#x771F;&#x5373;&#x53EF;&#xFF09;&#x771F;&#x771F;&#x4E3A;&#x771F;&#xFF0C;&#x771F;&#x5047;&#x4E3A;&#x771F;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-literal">true</span> || <span class="hljs-literal">false</span> );
    <span class="hljs-comment">//&#xFF01;&#x975E; &#x53D6;&#x53CD;</span>
    <span class="hljs-built_in">console</span>.log( !<span class="hljs-literal">false</span> );
    <span class="hljs-keyword">var</span> num2 = <span class="hljs-literal">true</span>;
    <span class="hljs-comment">//&#x5207;&#x6362;&#x65F6;</span>
    num2 = !num2;
</code></pre>
<h5 id="4-&#x4E09;&#x76EE;&#x8FD0;&#x7B97;&#x7B26;">4. &#x4E09;&#x76EE;&#x8FD0;&#x7B97;&#x7B26;</h5>
<pre><code>    &#x6761;&#x4EF6;?true&#x7684;&#x6267;&#x884C;:false&#x7684;&#x6267;&#x884C;
</code></pre><h5 id="5-&#x4F4D;&#x8FD0;&#x7B97;">5. &#x4F4D;&#x8FD0;&#x7B97;</h5>
<pre><code class="lang-js">    <span class="hljs-comment">//&#x4F4D;&#x8FD0;&#x7B97;&#x6BD4;&#x4E58;&#x9664;&#x7684;&#x6027;&#x80FD;&#x8981;&#x597D;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&quot;&#x4F4D;&#x8FD0;&#x7B97;&lt;&lt;&quot;</span> , <span class="hljs-number">2</span> &lt;&lt; <span class="hljs-number">1</span> );
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&quot;&#x4F4D;&#x8FD0;&#x7B97;&gt;&gt;&quot;</span> , <span class="hljs-number">2</span> &gt;&gt; <span class="hljs-number">1</span> );
</code></pre>
<h5 id="6-&#x65E0;&#x7B26;&#x53F7;&#x4F4D;&#x8FD0;&#x7B97;">6. &#x65E0;&#x7B26;&#x53F7;&#x4F4D;&#x8FD0;&#x7B97;</h5>
<pre><code class="lang-js">    <span class="hljs-comment">//&#x8D1F;&#x6570;&#x5B58;&#x7684;&#x662F;&#x8865;&#x7801;&#xFF0C;&#x8FD0;&#x7B97;&#x65F6;&#x6C42;&#x56DE;&#x6B63;&#x503C;&#xFF0C;&#x5728;&#x6C42;&#x4F4D;&#x8FD0;&#x7B97;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">&quot;&#x4F4D;&#x8FD0;&#x7B97;&gt;&gt;&gt;&quot;</span> , <span class="hljs-number">-9</span> &gt;&gt;&gt; <span class="hljs-number">1</span> );
</code></pre>
<h3 id="&#x6D41;&#x7A0B;&#x63A7;&#x5236;">&#x6D41;&#x7A0B;&#x63A7;&#x5236;</h3>
<h5 id="1-if--else-">1. if( ){ }else{ }</h5>
<pre><code class="lang-js">    <span class="hljs-comment">// prompt&#x4E0D;&#x80FD;&#x5B9A;&#x5236;</span>
    <span class="hljs-keyword">var</span> score = prompt(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x5206;&#x6570;&quot;</span>);  
    <span class="hljs-comment">// &#x8FD4;&#x56DE;string&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;</span>
    <span class="hljs-comment">// &#x5F3A;&#x5236;&#x8F6C;&#x6362; parseFloat&#xFF08;score&#xFF09; &#x6216;&#x8005; Number&#xFF08;score&#xFF09;</span>
    <span class="hljs-built_in">console</span>.log( <span class="hljs-built_in">parseFloat</span>(score) );

    <span class="hljs-comment">// &#x6709;&#x8303;&#x56F4;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF1A; 0 &lt; Number(score) &amp;&amp; Number(score) &lt; 100</span>
    <span class="hljs-keyword">if</span>( <span class="hljs-built_in">isNaN</span>( <span class="hljs-built_in">Number</span>(score) ) ){   
        <span class="hljs-comment">//&#x68C0;&#x67E5;&#x7528;&#x6237;&#x8F93;&#x5165;&#x7684;&#x662F;&#x4E0D;&#x662F;&#x4E2A;&#x6570;&#x5B57;</span>
        alert(<span class="hljs-string">&quot;&#x8F93;&#x5165;&#x4E0D;&#x5408;&#x6CD5;&quot;</span>)
    }<span class="hljs-keyword">else</span>{
        <span class="hljs-comment">//&#x5DF2;&#x68C0;&#x67E5;&#x6570;&#x636E;&#x662F;&#x6570;&#x5B57;</span>
        <span class="hljs-keyword">if</span>( score &gt;= <span class="hljs-number">90</span> ){
            alert(<span class="hljs-string">&quot;&#x4F18;&#x79C0;&quot;</span>);
        }
        <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>( score &gt;= <span class="hljs-number">70</span> ){
            alert(<span class="hljs-string">&quot;&#x826F;&#x597D;&quot;</span>);
        }
        <span class="hljs-keyword">else</span>{
            alert(<span class="hljs-string">&quot;&#x8FD8;&#x5DEE;&#x4E00;&#x70B9;&quot;</span>);
        }
    }
</code></pre>
<h5 id="2-&#x4E09;&#x76EE;&#x8FD0;&#x7B97;&#x7B26;">2. &#x4E09;&#x76EE;&#x8FD0;&#x7B97;&#x7B26;</h5>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> a = <span class="hljs-number">5</span>;
<span class="hljs-comment">//a&gt;=5?console.log(&quot;a&gt;=5&quot;) :console.log(&quot;a&lt;5&quot;) ;</span>
a&gt;=<span class="hljs-number">5</span>? (a&gt;<span class="hljs-number">10</span>?<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;a&gt;10&quot;</span>): <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x5C0F;&#x4E8E;10&#x5927;&#x4E8E;5&quot;</span>) ):<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;a&lt;5&quot;</span>) ;
</code></pre>
<h5 id="3-switch">3. switch</h5>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> pro = prompt(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;a/b/c&#x4EFB;&#x610F;&#x4E00;&#x4E2A;&#x5B57;&#x6BCD;&quot;</span>)
<span class="hljs-keyword">switch</span>(pro){
<span class="hljs-keyword">case</span><span class="hljs-string">&quot;a&quot;</span>:<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;case a&quot;</span>);<span class="hljs-keyword">break</span>;
<span class="hljs-keyword">case</span><span class="hljs-string">&quot;b&quot;</span>:<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;case b&quot;</span>);<span class="hljs-keyword">break</span>;
<span class="hljs-keyword">case</span><span class="hljs-string">&quot;c&quot;</span>:<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;case c&quot;</span>);<span class="hljs-keyword">break</span>;
<span class="hljs-keyword">default</span>:<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x4F60;&#x53C8;&#x5F00;&#x59CB;&#x4E86;&quot;</span>);<span class="hljs-keyword">break</span>;
}
</code></pre>
<h3 id="&#x5FAA;&#x73AF;">&#x5FAA;&#x73AF;</h3>
<h5 id="1-while-">1. while( )</h5>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">while</span>(i&lt;<span class="hljs-number">10</span>){
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;while&#xFF1A;&quot;</span>, i++);
    }
</code></pre>
<h5 id="2-dowhile--&#x5148;&#x4E0A;&#x8F66;&#x540E;&#x8865;&#x7968;-">2. do...while ( &#x5148;&#x4E0A;&#x8F66;&#x540E;&#x8865;&#x7968; )</h5>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> j = <span class="hljs-number">10</span>;
    <span class="hljs-keyword">do</span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;do...while:&quot;</span>,j++);
    }<span class="hljs-keyword">while</span>(j&lt;<span class="hljs-number">10</span>)
</code></pre>
<h5 id="3-for--">3. for( ){ }</h5>
<pre><code class="lang-js">    <span class="hljs-keyword">for</span>( <span class="hljs-keyword">var</span> k=<span class="hljs-number">1</span> ; k&lt;<span class="hljs-number">6</span> ; k++){
        <span class="hljs-built_in">console</span>.log(k);
        <span class="hljs-keyword">for</span>( <span class="hljs-keyword">var</span> l=<span class="hljs-number">1</span>; l&lt;<span class="hljs-number">4</span>; l++ ){
            <span class="hljs-built_in">console</span>.log(k*l);
        }
    }
    [
        {name:<span class="hljs-string">&quot;&#x5E7F;&#x4E1C;&#x7701;&quot;</span>,
          city:[{name:<span class="hljs-string">&quot;&#x5E7F;&#x5DDE;&#x5E02;&quot;</span>},{name:<span class="hljs-string">&quot;&#x6DF1;&#x5733;&#x5E02;&quot;</span>}]
          },
          {name:<span class="hljs-string">&quot;&#x5E7F;&#x897F;&#x7701;&quot;</span>}
    ]
    <span class="hljs-comment">//break    &#x4E2D;&#x65AD;&#xFF0C;&#x8DF3;&#x51FA;&#x5FAA;&#x73AF;</span>
    <span class="hljs-comment">//continue &#x8DF3;&#x51FA;&#x6863;&#x6B21;&#x5FAA;&#x73AF;</span>
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> i=<span class="hljs-number">0</span>; i&lt;<span class="hljs-number">5</span>; i++){
        <span class="hljs-keyword">if</span>( i == <span class="hljs-number">2</span> ){
    <span class="hljs-comment">//        break;</span>
            <span class="hljs-keyword">continue</span>;
        }
        <span class="hljs-built_in">console</span>.log(i);
    }
</code></pre>
<p><strong>for&#x5D4C;&#x5957;&#xFF1A;</strong><br>1.&#x5185;&#x5FAA;&#x73AF;&#x672A;&#x7ED3;&#x675F;&#x65F6;&#xFF0C;&#x5916;&#x5FAA;&#x73AF;&#x53EF;&#x7406;&#x89E3;&#x4E3A;&#x4E00;&#x4E2A;&#x6682;&#x65F6;&#x56FA;&#x5B9A;&#x7684;&#x503C;<br>2.&#x4F8B;&#x5982;&#x4E58;&#x6CD5;&#x8868;&#x6216;&#x8005;&#x4E8C;&#x7EA7;&#x8054;&#x52A8;    </p>
<p>&#x7EC3;&#x4E60;&#xFF1A;&#x5FAA;&#x73AF;10&#x6B21;&#xFF0C;&#x8BA9;&#x8BA1;&#x7B97;&#x5668;&#x4ECE;0&#x5F00;&#x59CB;&#x81EA;&#x589E;&#xFF0C;&#x6392;&#x9664;&#x5076;&#x6570;&#x5E76;&#x6253;&#x5370;&#x51FA;&#x6765;        </p>
<pre><code class="lang-js">    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> c=<span class="hljs-number">0</span>; c&lt;<span class="hljs-number">10</span>; c++){
        <span class="hljs-keyword">if</span>( c%<span class="hljs-number">2</span> == <span class="hljs-number">1</span> ){
            <span class="hljs-keyword">continue</span>;
        }
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;counter:&quot;</span>,c);
        <span class="hljs-comment">//&#x8F93;&#x51FA;&#x5230;&#x9875;&#x9762;</span>
        <span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&lt;h1&gt;&quot;</span>+ c +<span class="hljs-string">&quot;&lt;/h1&gt;&quot;</span>)
    }
</code></pre>
<h1 id="&#x51FD;&#x6570;">&#x51FD;&#x6570;</h1>
<ul>
<li>&#x53C2;&#x6570;&#xFF1A;&#x5F62;&#x53C2;&#x548C;&#x5B9E;&#x53C2;&#x5176;&#x5B9E;&#x662F;&#x4E24;&#x4E2A;&#x72EC;&#x7ACB;&#x7684;&#x4E2A;&#x4F53;&#xFF0C;&#x6240;&#x4EE5;&#x547D;&#x540D;&#x53EF;&#x4EE5;&#x91CD;&#x540D;&#xFF1B;    </li>
<li>arguments&#x662F;&#x51FD;&#x6570;&#x5185;&#x4E00;&#x4E2A;&#x63A5;&#x53D7;&#x53C2;&#x6570;&#x4F20;&#x5165;&#x7684;&#x5217;&#x8868;&#x3002;    </li>
<li>&#x51FD;&#x6570;&#x88AB;&#x8C03;&#x7528;&#x65F6;&#xFF0C;&#x5F62;&#x53C2;&#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;arguments&#x81EA;&#x52A8;&#x58F0;&#x660E;&#x5F62;&#x53C2;&#x540D;&#x5B57;&#x5E76;&#x4E14;&#x8D4B;&#x503C;&#x3002;</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> a=<span class="hljs-number">1</span>,b=<span class="hljs-number">2</span>;
    <span class="hljs-comment">// &#x58F0;&#x660E;&#x63D0;&#x524D;</span>
    add(a,b);
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">a,b</span>)</span>{
        <span class="hljs-keyword">var</span> a &#xFF0C;b&#xFF1B;
        <span class="hljs-keyword">if</span>(<span class="hljs-built_in">arguments</span>[<span class="hljs-number">0</span>]){
            a=<span class="hljs-built_in">arguments</span>[<span class="hljs-number">0</span>];
        }
        <span class="hljs-keyword">if</span>(<span class="hljs-built_in">arguments</span>[<span class="hljs-number">1</span>]){
            b=<span class="hljs-built_in">arguments</span>[<span class="hljs-number">1</span>];
        }
        <span class="hljs-keyword">if</span>(<span class="hljs-built_in">arguments</span>[<span class="hljs-number">2</span>]){
            c=<span class="hljs-built_in">arguments</span>[<span class="hljs-number">2</span>];
        }
        <span class="hljs-built_in">console</span>.log(a,b,<span class="hljs-built_in">arguments</span>[<span class="hljs-number">2</span>]);
        <span class="hljs-keyword">return</span> a+b;
    }

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">html</span>(<span class="hljs-params"></span>)</span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">arguments</span>.length)
        <span class="hljs-keyword">if</span>(<span class="hljs-built_in">arguments</span>.length==<span class="hljs-number">0</span>){
            <span class="hljs-comment">//&#x83B7;&#x53D6;&#x529F;&#x80FD;</span>
        }
        <span class="hljs-keyword">if</span>(<span class="hljs-built_in">arguments</span>.length==<span class="hljs-number">1</span>){
            <span class="hljs-comment">//&#x66FF;&#x6362;&#x529F;&#x80FD;</span>
        }
    }
    html();
</code></pre>
<p>&#x7EC3;&#x4E60;&#xFF1A;&#x52A0;&#x6CD5;&#x51FD;&#x6570;&#x53C2;&#x6570;&#x662F;&#x4E0D;&#x5B9A;&#x9879;</p>
<pre><code class="lang-js">    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addMore</span>(<span class="hljs-params"></span>)</span>{
        <span class="hljs-keyword">var</span> result = <span class="hljs-number">0</span>;
        <span class="hljs-comment">//&#x91CD;&#x590D;&#x7ED9;&#x7ED3;&#x679C;&#x6DFB;&#x52A0;&#x4F20;&#x5165;&#x53C2;&#x6570;&#x7684;&#x503C;&#xFF0C;&#x6B21;&#x6570;&#x7531;&#x4F20;&#x5165;&#x53C2;&#x6570;&#x7684;&#x4E2A;&#x6570;&#x51B3;&#x5B9A;</span>
        <span class="hljs-keyword">for</span>( <span class="hljs-keyword">var</span> i=<span class="hljs-number">0</span>; i&lt;<span class="hljs-built_in">arguments</span>.length ;i++ ){
            reslut +=<span class="hljs-built_in">arguments</span>[i];
        }
        <span class="hljs-keyword">return</span> result;
    }
    addMore();
</code></pre>
<p>&#x5168;&#x5C40;&#x4F5C;&#x7528;&#x57DF;   ( &#x6D4F;&#x89C8;&#x5668;&#xFF1A;window  node:global )</p>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> a=<span class="hljs-number">1</span>;
    <span class="hljs-comment">//window.a = 100;</span>
    <span class="hljs-comment">//&#x4F5C;&#x7528;&#x57DF;&#x94FE;&#xFF1A;window-&gt;funArea-&gt;funArea2</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">funArea</span>(<span class="hljs-params"></span>)</span>{
        <span class="hljs-keyword">var</span> a=<span class="hljs-number">10</span>;<span class="hljs-comment">//&#x51FD;&#x6570;&#x4F5C;&#x7528;&#x57DF;</span>
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;a&#x7684;&#x503C;&quot;</span>,a);
        funArea2()<span class="hljs-comment">//&#x8C03;&#x7528;</span>
        <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">funArea2</span>(<span class="hljs-params"></span>)</span>{
            <span class="hljs-keyword">var</span> a=<span class="hljs-number">100</span>;
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;a&#x7684;&#x503C;&quot;</span>,a);
        }
    }
    <span class="hljs-comment">//window-&gt;funArea3</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">funArea3</span>(<span class="hljs-params"></span>)</span>{
        <span class="hljs-keyword">var</span> a=<span class="hljs-number">100</span>;<span class="hljs-comment">//&#x51FD;&#x6570;&#x4F5C;&#x7528;&#x57DF;</span>
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;a&#x7684;&#x503C;&quot;</span>,a);
    }
    funArea();
</code></pre>
<p>var&#x58F0;&#x660E;&#x63D0;&#x524D;&#xFF1A;&#x5148;&#x7ED9;&#x53D8;&#x91CF;&#x5F00;&#x8F9F;&#x7A7A;&#x95F4;&#xFF0C;&#x5C3D;&#x7BA1;&#x503C;&#x4E3A;undefined&#xFF0C;&#x5141;&#x8BB8;&#x91CD;&#x590D;&#x58F0;&#x660E;&#x3002;    </p>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> aaa=<span class="hljs-string">&quot;123&quot;</span>
    <span class="hljs-built_in">console</span>.log(aaa);
    <span class="hljs-keyword">var</span> aaa=<span class="hljs-string">&quot;456&quot;</span>
    <span class="hljs-built_in">console</span>.log(aaa);
</code></pre>
<p>let(ES6)&#xFF1A;&#x4E0D;&#x5141;&#x8BB8;&#x91CD;&#x590D;&#x58F0;&#x660E;&#xFF0C;&#x5757;&#x7EA7;&#x4F5C;&#x7528;&#x57DF;&#xFF08;&#x53EF;&#x4EE5;&#x8FD0;&#x7528;&#x5728;&#x4E00;&#x4E9B;&#x6CA1;&#x6709;&#x72EC;&#x7ACB;&#x4F5C;&#x7528;&#x57DF;&#x7684;&#x4EE3;&#x7801;&#x5757;&#xFF0C;&#x5982;for&#xFF09;</p>
<pre><code class="lang-js">    <span class="hljs-keyword">let</span> aaa = <span class="hljs-string">&quot;789&quot;</span>
    <span class="hljs-keyword">var</span> i = <span class="hljs-number">10</span>;
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">let</span> i=<span class="hljs-number">1</span> ;i&lt;<span class="hljs-number">2</span> ; i++){
        <span class="hljs-comment">//for&#x5185;&#x4F7F;&#x7528;&#x7684;i&#x662F;&#x4E00;&#x4E2A;&#x5757;&#x7EA7;&#x4F5C;&#x7528;&#x57DF;&#x91CC;&#x7684;i</span>
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;for&#xFF1A;&quot;</span>,i)
    }
    <span class="hljs-comment">//window.i</span>
    <span class="hljs-built_in">console</span>.log(i)
</code></pre>
<blockquote>
<p>const&#x58F0;&#x660E;&#x5E38;&#x91CF;<br>1.&#x548C;let&#x4E00;&#x6837;&#xFF0C;&#x4E0D;&#x53EF;&#x91CD;&#x590D;&#x58F0;&#x660E;<br>2.&#x58F0;&#x660E;&#x7684;&#x540C;&#x65F6;&#xFF0C;&#x5FC5;&#x987B;&#x8D4B;&#x503C;<br>3.&#x58F0;&#x660E;&#x540E;&#x4E0D;&#x53EF;&#x518D;&#x8D4B;&#x503C;    </p>
</blockquote>
<pre><code class="lang-js">    <span class="hljs-keyword">const</span> bbb=<span class="hljs-number">1000</span>;
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">people</span>(<span class="hljs-params">name,age</span>)</span>{
        <span class="hljs-keyword">const</span> sex = <span class="hljs-string">&quot;man&quot;</span>;
        <span class="hljs-keyword">if</span>(name==<span class="hljs-literal">undefined</span>){
            alert(<span class="hljs-string">&quot;name&#x503C;&#x662F;&#x5FC5;&#x586B;&quot;</span>);
            <span class="hljs-keyword">return</span>;
        }
        <span class="hljs-keyword">if</span> (age==<span class="hljs-literal">undefined</span>) {
            age=<span class="hljs-number">18</span>;<span class="hljs-comment">//&#x9ED8;&#x8BA4;&#x503C;</span>
        }
    }
    people()
</code></pre>
<ol>
<li>&#x547D;&#x540D;&#x51FD;&#x6570;<pre><code class="lang-js"> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">reduce</span>(<span class="hljs-params"> </span>)</span>{ }
</code></pre>
</li>
<li>&#x51FD;&#x6570;&#x7684;&#x8868;&#x8FBE;&#x5F0F; ( &#x53D8;&#x91CF;&#x63A5;&#x6536;&#x4E00;&#x4E2A;&#x533F;&#x540D;&#x51FD;&#x6570; )<pre><code class="lang-js"> <span class="hljs-keyword">var</span> add = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>)</span>{
     <span class="hljs-keyword">return</span> a+b;  
 }
 add();
 <span class="hljs-comment">//&#x547D;&#x540D;&#x51FD;&#x6570;&#x8868;&#x8FBE;&#x5F0F;</span>
 <span class="hljs-comment">//xyz&#x51FD;&#x6570;&#x5F53;&#x524D;&#x7684;&#x5BB9;&#x5668;&#x662F;abc</span>
 <span class="hljs-keyword">var</span> abc = <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">xyz</span>(<span class="hljs-params"></span>)</span>{
     <span class="hljs-built_in">console</span>.log(xyz)
 }
 abc();<span class="hljs-comment">//console.log(abc,xyz)</span>
 <span class="hljs-comment">//return&#x8FD4;&#x56DE;&#x503C;&#xFF0C;&#x4E2D;&#x65AD;&#x51FD;&#x6570;&#x7684;&#x8FD0;&#x884C;&#xFF08;&#x53EA;&#x80FD;&#x653E;&#x5728;&#x51FD;&#x6570;&#x4E2D;&#x4F7F;&#x7528;&#xFF09;</span>
</code></pre>
</li>
<li><p>try{ }catch( e ){ }</p>
<pre><code class="lang-js"> <span class="hljs-keyword">try</span> {
     &#x6267;&#x884C;&#x4EE3;&#x7801;
 }<span class="hljs-keyword">catch</span>&#xFF08;e&#xFF09;{
     &#x6355;&#x83B7;&#x9519;&#x8BEF;;e&#x4EE3;&#x8868;&#x9519;&#x8BEF;;&#x5177;&#x6709;&#x72EC;&#x7ACB;&#x7684;&#x4F5C;&#x7528;&#x57DF;
 }

 <span class="hljs-built_in">console</span>.warn()     <span class="hljs-comment">//&#x6253;&#x5370;&#x8B66;&#x544A;</span>
 <span class="hljs-built_in">console</span>.error()    <span class="hljs-comment">//&#x6253;&#x5370;&#x9519;&#x8BEF;</span>
 <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">&quot;&#x62A5;&#x9519;&#x63D0;&#x793A;&quot;</span>)
 <span class="hljs-comment">//&#x4E3B;&#x52A8;&#x629B;&#x51FA;&#x9519;&#x8BEF;</span>
 <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">&quot;test error&quot;</span>);

 <span class="hljs-keyword">var</span> e=<span class="hljs-number">1</span>;
 <span class="hljs-keyword">try</span>{
     <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;try&quot;</span>,abc)
 }<span class="hljs-keyword">catch</span>(e){
     <span class="hljs-comment">//&#x5982;&#x679C;try&#x4E2D;&#x6CA1;&#x6709;&#x9519;&#x8BEF;&#xFF0C;&#x5219;&#x4E0D;&#x4F1A;&#x6267;&#x884C;</span>
     <span class="hljs-keyword">var</span> err = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">&quot;xyz&#x6CA1;&#x6709;&#x6302;&#x8F7D;&#x5728;&#x5168;&#x5C40;&#x4E0A;&quot;</span>)
     <span class="hljs-built_in">console</span>.error( err );
     <span class="hljs-built_in">console</span>.log( e )
 }<span class="hljs-keyword">finally</span>{
     <span class="hljs-comment">//&#x6700;&#x540E;&#x4E00;&#x6B65;</span>
     <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;finally&quot;</span>,e)
 }
 <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x6700;&#x540E;&#x5566;&quot;</span>)
</code></pre>
</li>
</ol>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="变量&作用域&垃圾收集.html" class="navigation navigation-prev " aria-label="Previous page: 3.6 变量 & 作用域 & 垃圾收集">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="面向对象.html" class="navigation navigation-next " aria-label="Next page: 3.8 面向对象的程序设计">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"3.7 流程控制 & 函数","level":"1.5.16","depth":2,"next":{"title":"3.8 面向对象的程序设计","level":"1.5.17","depth":2,"path":"JS/面向对象.md","ref":"JS/面向对象.md","articles":[]},"previous":{"title":"3.6 变量 & 作用域 & 垃圾收集","level":"1.5.15","depth":2,"path":"JS/变量&作用域&垃圾收集.md","ref":"JS/变量&作用域&垃圾收集.md","articles":[]},"dir":"ltr"},"config":{"plugins":["toggle-chapters","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"toggle-chapters":{},"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"gitbook电子书","gitbook":"*","description":"记录前端相关的知识点以及一些示例的demo"},"file":{"path":"JS/流程控制&函数.md","mtime":"2019-03-22T03:20:42.375Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-09-06T08:37:43.293Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

